package com.osfw.activiti.enums.resource;


import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * 流程定义操作类型
 */
public enum ProcdefActionType {

    STAGING(0, "暂存"),
    RELEASE(1, "发布"),
    FALLBACK(2, "回退"),
    ACTIVATION(3, "激活"),
    SUSPEND(4, "挂起"),
    SHARE(5, "分享"),
    CANCEL_SHARE(6, "取消分享"),
    DELETE(-1, "删除");

    private Integer action;
    private String name;

    ProcdefActionType(Integer action, String name) {
        this.action = action;
        this.name = name;
    }

    public Integer getAction() {
        return action;
    }

    public String getName() {
        return name;
    }


    public static ProcdefActionType getActionType(Integer action) {
        for (ProcdefActionType typeEnum : values()) {
            if (typeEnum.getAction().intValue() == action.intValue()) {
                return typeEnum;
            }
        }
        return null;
    }

    public static Map<Integer, String> getProcdefActionTypeList() {
        HashMap<Integer, String> map = new LinkedHashMap<>();
        for (ProcdefActionType typeEnum : values()) {
            map.put(typeEnum.getAction(), typeEnum.getName());
        }
        return map;
    }

}
